package afesocketserver;

import java.util.*;
import javax.swing.*;

public class UpdateClientCountTask extends TimerTask {
    protected JLabel clientsLabel;
    protected GameServer chatServer;

    public UpdateClientCountTask(GameServer chatServer, JLabel clientsLabel) {
        this.chatServer = chatServer;
        this.clientsLabel = clientsLabel;
    }

    public void run() {
        int count = this.chatServer.getClientCount();
        String msg = count + " client" + ((count != 1) ? "s" : "");
        this.clientsLabel.setText(msg);
    }   
}
